<%-- 
    Document   : search_email_address.jsp
    Created on : Mar 25, 2012, 3:58:16 PM
    Author     : duongna
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Search Email Address</title>
        <script lang="JavaScript">
         function validate(form) {
             if (form.emailAddress.value == "") {
                 alert("Please fill in your email address");
             }
             else {
                 form.submit();
             }
         }
        </script>
    </head>
    <body>
        <%@page import="business.*" %>
        
        <%
        User user = (User) request.getAttribute("user");
        if (user == null) user = new User("", "", "");
        %>
        <table>
            <form action="SearchEmailAddressServlet" method="get">
                <tr>
                    <td align="right">Email Address:</td>
                    <td><input type="text" name="emailAddress"></td>
                </tr>
                <tr>
                    <td><input type="button" value="Search"
                               onclick="validate(this.form)"></td>
                </tr>
            </form>

            <% if (user != null) { %>
            <tr>
                <td colspan="2"><h2>Result:</h2></td>
            </tr>
            <tr>
                <td align="right">First Name:</td>
                <td><%= user.getFirstName() %></td>
            </tr>
            <tr>
                <td align="right">Last Name:</td>
                <td><%= user.getLastName() %></td>
            </tr>
            <% 
            }
                   else {
                  out.println("<tr>"
                          + "<td><h2> Not found<h2></td>"
                          + "</tr>");
                   }       
            %>
        </table>
    </body>
</html>
